<template>
	<view>
		<view class="friendNumberWp">
			<view class="friendNumber">
				共同好友数量 {{commonFriendList.length?commonFriendList.length:0}}
			</view>
		</view>
		<view class="cardWp " v-for="(item,i) in commonFriendList" :key="i">
			<view class="card" @click.stop="handleMore(item)">
				<view class="left">
					<view class="imgWp">
						<img :src="item.head" alt="">
					</view>
					<view class="info">
						<view class="name">
							{{item.name?item.name:''}}
						</view>
						<view class="title">
							{{item.position?item.position:''}}
						</view>
						<view class="company">
							{{item.company?item.company:''}}
						</view>
					</view>
				</view>
				<!-- <view class="right">
					<view class="more" >
						<img src="https://file.casugn.com/storecompcard/temp/forward_1654829943398.png" alt=""
							srcset="">
					</view>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		data() {
			return {
				friendOpenId: '',
				commonFriendList: [],
				openId: ''

			}
		},
		onLoad(opt) {
			if (opt.friendOpenId) {
				this.friendOpenId = opt.friendOpenId
				console.log(this.friendOpenId);
				this.handleCommonFriendList()
			}
		},
		computed: {
			...mapState(['userInfo'])
		},

		methods: {
			//获取用户和好友的共同人脉列表

			async handleCommonFriendList() {
				let data = uni.getStorageSync('openId')
				if (data.openid) {
					this.openId = data.openid
				}
				let payload = {
					friendOpenId: this.friendOpenId,
					openId: this.openId
				}
				let res = await this.$api.querySameFriends(payload)
				console.log(res);
				if (res.success) {

					this.commonFriendList = res.result
					console.log(this.commonFriendList);
				}
			},
			handleMore(item) {
				console.log(item);
				uni.navigateTo({
					url: '/pagesCard/friendMainPage/friendMainPage?cardId=' + item.friendId
				})
			}
		}
	}
</script>

<style lang="scss">
	.friendNumberWp {
		margin: 30upx;

		.friendNumber {
			font-size: 36upx;
			color: #333333;
		}
	}

	.cardWp {
		margin: 30upx;
		background: #FFFFFF;
		box-shadow: 0px 1px 4px 0px rgba(66, 60, 254, 0.4);
		border-radius: 30upx;

		.card {
			padding: 50upx 40upx;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.left {
				display: flex;
				align-items: center;

				.imgWp {
					width: 110upx;
					height: 110upx;

					img {
						width: 100%;
						height: 100%;
					}
				}

				.info {
					margin-left: 20upx;

					.name {
						font-size: 30upx;
						font-weight: 500;
						color: #000000;
						line-height: 36upx;
					}

					.title {
						font-size: 24upx;
						font-family: PingFang SC;
						font-weight: 400;
						color: #666666;
						line-height: 36upx;
					}

					.company {
						font-size: 24upx;
						font-family: PingFang SC;
						font-weight: 400;
						color: #333333;
						line-height: 36upx;
					}
				}

			}

			.right {
				.more {
					margin-top: -40upx;
					width: 50upx;
					height: 20upx;

					img {
						width: 100%;
						height: 100%;
					}
				}
			}
		}
	}
</style>
